package com.example.stock.controller;

import cn.hutool.core.lang.Assert;
import com.example.stock.entity.eo.RuleEo;
import com.example.stock.entity.eo.UnitEo;
import com.example.stock.service.IRuleService;
import com.example.stock.vo.PlusVo;
import com.example.stock.vo.UnitCreateForm;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.print.attribute.IntegerSyntax;
import java.time.LocalDateTime;
import java.util.*;

@RestController
@RequestMapping("/rule")
@Slf4j
public class RuleController {

    @Resource
    private IRuleService ruleService;

    @GetMapping("list")
    @ApiOperation("策略列表")
    public List<RuleEo> list(){
        List<RuleEo> ruleEos = ruleService.list();
        return ruleEos;
    }

    @GetMapping("get")
    @ApiOperation("id查询")
    public RuleEo get(@RequestParam Integer id){
        RuleEo byId = ruleService.getById(id);
        return byId;
    }

    @PostMapping("save")
    public Map create(@RequestBody @Validated RuleEo ruleEo) {
        ruleService.save(ruleEo);
        return new HashMap();
    }

    @PostMapping("delete")
    public Map delete(@RequestParam Integer id) {
        ruleService.deleteById(id);
        return new HashMap();
    }


}
